package com.sxm.yiwei.activitis;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;
import com.sxm.yiwei.tools.CastTime;

/**
 * 公告详情 异常订单详情
 */

public class NoticeItemContentActivity extends BaseActivity implements View.OnClickListener{

    private ImageView noticacontentback;
    private TextView noticecontenttitle;
    private ImageView noticecontenttypeimg;
    private TextView noticecontentname;
    private TextView noticecontentbookcode;
    private TextView noticecontentuptime;
    private TextView noticecontentresulttitle;
    private TextView noticontentresultcontent;
    private TextView noticecontentresulttime;
    private ImageView backmain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notice_item_content);
        Intent intent = getIntent();
        String code = intent.getStringExtra("code");
        String kind = intent.getStringExtra("kind");
        String result = intent.getStringExtra("result");
        String shopname = intent.getStringExtra("shopname");
        String resultkind = intent.getStringExtra("resultkind");
        String time = intent.getStringExtra("time");
        String resulttime = intent.getStringExtra("resulttime");
        String type = intent.getStringExtra("type");
        String userName = intent.getStringExtra("userName");
        String userPhone = intent.getStringExtra("userPhone");
        initNoticeContent();
        Integer typyImg = Integer.valueOf(type);
        if (TextUtils.isEmpty(shopname)){
            noticecontentname.setText("");
        }else if (TextUtils.isEmpty(kind)){
            noticecontentname.setText("");
        }else if (TextUtils.isEmpty(resultkind)){
            noticecontentresulttitle.setText("");
        }else if (TextUtils.isEmpty(result)){
            noticontentresultcontent.setText("");
        }else if (TextUtils.isEmpty(userName)){
            noticecontentbookcode.setText(""+"  ("+userPhone+")");
        }else if (TextUtils.isEmpty(userPhone)){
            noticecontentbookcode.setText(userName+"");
        }else {}
        noticecontentname.setText(shopname);
        noticecontenttitle.setText(kind);
        noticecontentuptime.setText(CastTime.startTime(Long.valueOf(time)));
        noticecontentresulttitle.setText(resultkind);
        noticontentresultcontent.setText(result);
        noticecontentresulttime.setText(CastTime.startTime(Long.valueOf(resulttime)));
        noticecontentbookcode.setText(userName+"  ("+userPhone+")");
        switch (typyImg){
                case 2000:// 订单申诉
                    noticecontenttypeimg.setImageResource(R.mipmap.ddss);
                    noticecontentbookcode.setVisibility(View.VISIBLE);
                    break;
                case 2001:// 意见建议
                    noticecontenttypeimg.setImageResource(R.mipmap.yjjyj);
                    break;
                case 2002:// 店铺举报
                    noticecontenttypeimg.setImageResource(R.mipmap.jb);
                    break;
                case 2003:// 实名认证
                    noticecontenttypeimg.setImageResource(R.mipmap.smrz);
                    break;
                case 2004:// 店铺审核
                    noticecontenttypeimg.setImageResource(R.mipmap.dpsh);
                    break;
                case 2005:// 服务审核
                    noticecontenttypeimg.setImageResource(R.mipmap.fwsh);
                    break;
                case 2006:// 充值
                    noticecontenttypeimg.setImageResource(R.mipmap.cz);
                    break;
                case 2007:// 提现
                    noticecontenttypeimg.setImageResource(R.mipmap.tx);
                    break;
                case 2008://一喂元等级
                    noticecontenttypeimg.setImageResource(R.mipmap.yyydj);
                    break;
                case 2009:// 服务保障金
                    noticecontenttypeimg.setImageResource(R.mipmap.bzjjn);
                    noticecontentbookcode.setVisibility(View.VISIBLE);
                    break;

        }

    }

    private void initNoticeContent() {
        noticacontentback = (ImageView) findViewById(R.id.noticecontent_back);
        noticecontenttitle = (TextView) findViewById(R.id.notice_item_title);
        noticecontenttypeimg = (ImageView) findViewById(R.id.noticecontent_typeimg);
        noticecontentname = (TextView) findViewById(R.id.noticecontent_name);
        noticecontentbookcode = (TextView) findViewById(R.id.noticecontent_booncode);
        noticecontentuptime = (TextView) findViewById(R.id.noticecontent_uptime);
        noticecontentresulttitle = (TextView) findViewById(R.id.noticecontent_resultt);
        noticontentresultcontent = (TextView) findViewById(R.id.noticecontent_result);
        noticecontentresulttime = (TextView) findViewById(R.id.noticecontent_resulttime);
        backmain = (ImageView) findViewById(R.id.msgnotice_backmain);
        noticacontentback.setOnClickListener(this);
        backmain.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.noticecontent_back:
                finish();
                break;
            case R.id.msgnotice_backmain:
                startActivity(new Intent(NoticeItemContentActivity.this, MainActivity.class));
                AppManager.getAppManager().finishAllActivity();

                break;
        }
    }
}
